<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:p="http://primefaces.org/ui" template="/templates/layout.xhtml">

	<ui:define name="ptitle">组织机构管理</ui:define>
	<ui:define name="pcontent">
		<h:form id="frm" >
    		<p:contextMenu for="vorgs">
		        <p:menuitem value="查看" update="msgs" actionListener="#{sysOrganMB.displaySelectedSingle}" icon="ui-icon-search" />
		        <p:menuitem value="增加" update="msgs" actionListener="#{sysOrganMB.displaySelectedSingle}" icon="ui-icon-plus"/>
		        <p:menuitem value="删除" update="vorgs" actionListener="#{sysOrganMB.deleteNode}" icon="ui-icon-minus"/>
		    </p:contextMenu>
			<p:growl id="msgs" showDetail="true" />			

			<p:treeTable id="vorgs" value="#{sysOrganMB.root}" var="vorg" editable="true" editMode="cell" 
				selectionMode="single" selection="#{sysOrganMB.selectedNode}" style="margin-top:0">
				
		        <p:ajax event="rowEdit" listener="#{sysOrganMB.onRowEdit}" update=":frm:msgs" />
        		<p:ajax event="rowEditCancel" listener="#{sysOrganMB.onRowCancel}" update=":frm:msgs" />
			        
		        <f:facet name="header">企业组织机构信息</f:facet>
		               
		        <p:column headerText="名称">
				    <p:cellEditor>
		                <f:facet name="output"><h:outputText value="#{vorg.name}" /></f:facet>
		                <f:facet name="input"><p:inputText value="#{vorg.name}" style="width:100%"/></f:facet>
		            </p:cellEditor>
		        </p:column>
		        <p:column headerText="部门ID">
				    <p:cellEditor>
		                <f:facet name="output"><h:outputText value="#{vorg.orgid}" /></f:facet>
		                <f:facet name="input"><p:inputText value="#{vorg.orgid}" style="width:100%"/></f:facet>
		            </p:cellEditor>		        
		        </p:column>
		        <p:column headerText="类型">
				    <p:cellEditor>
		                <f:facet name="output"><h:outputText value="#{vorg.dtype == 0 ? '叶节点' : '非叶节点'}" /></f:facet>
		                <f:facet name="input">		                	
		                	<p:selectOneMenu value="#{vorg.dtype}" effect="fold" style="width:100%">
								<f:selectItem itemLabel="叶节点" itemValue="1" />											
								<f:selectItem itemLabel="非叶节点" itemValue="0" />
							</p:selectOneMenu>	</f:facet>
		            </p:cellEditor>		        
		        </p:column>
		        <p:column headerText="状态">
				    <p:cellEditor>
		                <f:facet name="output"><h:outputText value="#{vorg.dactive == 1 ? '有效' : '失效'}" /></f:facet>
		                <f:facet name="input">		               		
		                	<p:selectOneMenu value="#{vorg.dactive}" effect="fold" style="width:100%">
								<f:selectItem itemLabel="有效" itemValue="1" />											
								<f:selectItem itemLabel="失效" itemValue="0" />
							</p:selectOneMenu>	
						</f:facet>
		            </p:cellEditor>		        
		        </p:column>
		        <p:column headerText="用户ID">
		            <h:outputText value="#{vorg.userid}" />
		        </p:column>
		        <p:column style="width:24px">
		            <p:commandLink update=":frm:deptPanel" oncomplete="PF('deptDialog').show()" title="View Detail" styleClass="ui-icon ui-icon-search">
		                <f:setPropertyActionListener value="#{vorg}" target="#{sysOrganMB.selectedNodeData}" />
		            </p:commandLink>
		        </p:column>
		    </p:treeTable>

		    <p:dialog id="dialog" header="部门信息详情" showEffect="fade" widgetVar="deptDialog"  resizable="false">
		        <p:outputPanel id="deptPanel">
		            <p:panelGrid  columns="2" columnClasses="label,value" rendered="#{not empty sysOrganMB.selectedNodeData}">
		                <h:outputLabel for="dorgid" value="部门ID: " />
		                <h:outputText id="dorgid" value="#{sysOrganMB.selectedNodeData.orgid}" style="font-weight:bold" /> 
		                <h:outputLabel for="dname" value="部门名称: " />
		                <h:outputText id="dname" value="#{sysOrganMB.selectedNodeData.name}" style="font-weight:bold" /> 
		                <h:outputLabel for="dtype" value="类型: " />
		                <h:outputText id="dtype" value="#{sysOrganMB.selectedNodeData.dtype}" style="font-weight:bold" />
		                <h:outputLabel for="dactive" value="类型: " />
		                <h:outputText id="dactive" value="#{sysOrganMB.selectedNodeData.dactive}" style="font-weight:bold" />
		                <h:outputLabel for="duserid" value="用户ID: " />
		                <h:outputText id="duserid" value="#{sysOrganMB.selectedNodeData.userid}" style="font-weight:bold" />
		            </p:panelGrid>
		        </p:outputPanel>
		    </p:dialog>
		    
		</h:form>

	</ui:define>
</ui:composition>

